/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.gr.jcash.dmp;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author gelson
 */
@Entity
@Table(name = "grupo", catalog = "jcash", schema = "public")
@NamedQueries({
    @NamedQuery(name = "Grupo.buscarTodos", query = "SELECT g FROM Grupo g"),
    @NamedQuery(name = "Grupo.buscarPorId", query = "SELECT g FROM Grupo g WHERE g.idGrp = :p0"),
    @NamedQuery(name = "Grupo.buscarPorGrpNome", query = "SELECT g FROM Grupo g WHERE g.grpNome = :p0"),
    @NamedQuery(name = "Grupo.buscarPorGrpDescricao", query = "SELECT g FROM Grupo g WHERE g.grpDescricao = :p0")})
public class Grupo extends EntidadeBase implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_grp", nullable = false)
    private Long idGrp;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "grp_nome", nullable = false, length = 20)
    private String grpNome;
    @Size(max = 100)
    @Column(name = "grp_descricao", length = 100)
    private String grpDescricao;
    @ManyToMany(mappedBy = "grupoCollection")
    private Collection<Usuario> usuarioCollection;

    public Grupo() {
    }

    public Long getIdGrp() {
        return idGrp;
    }

    public void setIdGrp(Long idGrp) {
        this.idGrp = idGrp;
    }

    public String getGrpNome() {
        return grpNome;
    }

    public void setGrpNome(String grpNome) {
        this.grpNome = grpNome;
    }

    public String getGrpDescricao() {
        return grpDescricao;
    }

    public void setGrpDescricao(String grpDescricao) {
        this.grpDescricao = grpDescricao;
    }

    public Collection<Usuario> getUsuarioCollection() {
        return usuarioCollection;
    }

    public void setUsuarioCollection(Collection<Usuario> usuarioCollection) {
        this.usuarioCollection = usuarioCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idGrp != null ? idGrp.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Grupo)) {
            return false;
        }
        Grupo other = (Grupo) object;
        if ((this.idGrp == null && other.idGrp != null) || (this.idGrp != null && !this.idGrp.equals(other.idGrp))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.com.gr.jcash.dmp.Grupo[ idGrp=" + idGrp + " ]";
    }

    @Override
    public void setId(Long id) {
        this.idGrp = id;
    }

    @Override
    public Long getId() {
        return idGrp;
    }
}
